package com.xszx.system.handle;

import com.xszx.server.dto.AjaxJson;
import com.xszx.server.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ControllerExceptionHandler {

    private static final Logger LOG = LoggerFactory.getLogger(ControllerExceptionHandler.class);

    @ExceptionHandler(value = BusinessException.class)
    @ResponseBody
    public AjaxJson businessExceptionHandler(BusinessException e) {
        LOG.error("业务异常：{}", e.getCode().getDesc());
        return AjaxJson.error(e.getCode().getDesc());
    }
}
